package org.feiye.studyday05;

import java.util.Scanner;

public class DigitalSum {

	public static void main(String[] args) {
		// 输入一个正整数，求他各位上的和，判断这个数能不能被他各位上的数的和整除
		Scanner input = new Scanner(System.in);
		int num;
		do {
		System.out.println("请输入一个正整数：");
			num = input.nextInt();
		} while (num < 0);
		int sum = 0;
		int k = num;
		while (k > 0) {
			sum += k % 10;
			k /= 10;
		}
		System.out.println("您输入的正整数所有位之和为：" + sum);
		String result = num % sum == 0 ? "可以整除" : "不可以整除";
		System.out.println(result);
	}

}
